<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name='viewport' content='width=device-width,initial-scale=1,user-scalable=no'>
    <meta name='apple-mobile-web-app-capable' content='yes'/>
    <meta name='apple-mobile-web-app-status-bar-style' content='black'/>
    <meta name='format-detection' content='telephone=no,email=no,adress=no'/>
    <title><?=$sys['web_site_title'];?><?=isset($page_title)?'-'.$page_title:'';?></title>
    <meta name='keywords' content='<?=$sys['web_site_keywords'];?>'>
    <meta name='description' content='<?=$sys['web_site_description'];?>'>
    <meta name='viewport' content='width=device-width,initial-scale=1,user-scalable=no'>
    <meta name='apple-mobile-web-app-capable' content='yes'/>
    <meta name='apple-mobile-web-app-status-bar-style' content='black'/>
    <meta name='format-detection' content='telephone=no,email=no,adress=no'/>
    <link rel='stylesheet' type='text/css' href='/static/m/library/m.css?v=1.1.3.1'>
    <link rel='stylesheet' type='text/css' href='/static/m/library/lib.css'>
    <link rel='stylesheet' type='text/css' href='/static/m/ttf/ttf.css'>
    <script src="/static/vendor/jquery.min.js?v=<?=env('version')?>"></script>
    <script type='text/javascript' src='/static/m/library/lib.js'></script>
    <script type='text/javascript' charset='UTF-8' src='/static/m/library/m.js?v=1.1.3.1'></script>
    <script type="text/javascript" src="/static/admin/common/layui/layui.js"></script>
    <script type="text/javascript" src="/static/vendor/function.js"></script>
</head>
<body>
<div class="swrap">
    <!--商品轮播图-->
    <div id="Touchslide" class="touch">
        <div class="tempWrap" style="overflow:hidden; position:relative;">
            <ul id="TouchMain" class="TouchMain"
                style="width: 1125px; position: relative; overflow: hidden; padding: 0px; margin: 0px; transition-duration: 200ms; transform: translate(-375px, 0px) translateZ(0px);">

                <?php if($goods_info['pics']):?>
                  <?php foreach($goods_info['pics'] as $k=>$v): ?>
                    <li style="display: table-cell; vertical-align: top; width: 375px;">
                        <img src="<?=$v?>">
                    </li>
                  <?php endforeach;?>
              <?php else:?>
                <li style="display: table-cell; vertical-align: top; width: 375px;">
                    <img src="<?=$goods_info['pic']?>">
                </li>
              <?php endif;?>

            </ul>
        </div>
        <ul id="TouchSort" class="TouchSort">
          <?php if($goods_info['pics']):?>
            <?php foreach($goods_info['pics'] as $k=>$v): ?>
              <li <?php if($k == 0):?> class="on" <?php endif;?>><?=$k?></li>
            <?php endforeach;?>
        <?php else:?>
          <li class="on">1</li>
        <?php endif;?>
        </ul>
    </div>
    <!--商品详情-->
    <div class="parems">
        <!--商品详情-->
        <div class="scroller">
            <div class="cut_one">
                <dl class="cut_dl">
                    <dt>
                        <span class="f_price key">￥<em><?=$goods_info['price']?></em></span>
                        <span class="s_price">￥<?=$goods_info['market_price']?></span>
                    </dt>
                    <dd>
                        <?=$goods_info['title']?>
                    </dd>
                </dl>
                <div class="cut_collec">
                    <i <?php if($iscollect==1):?>style="color:#ff9900;"<?php else:?>style="color:#555;"<?php endif;?> class="icon-star-empty icon-2x" onclick="mGoodsCollect(<?=$goods_info['goods_id']?>)"></i>收藏
                </div>
            </div>
            <input type="hidden" id="goods_id" value="<?=$goods_info['id']?>"/>
            <!--正品保障-->
            <!--活动-->
            <div class="cutWrap new_cut">
                <span class="cut_labs" style="width:60px;">温馨提示</span><?=$com['word']['wxts']['content']?>
                <!--活动-->
                <div class="cutWrap cut_three cF">
                    <span class="re_z"><i></i>正品保障</span>
                    <span class="re_z"><i></i>急速发货</span>
                    <span class="re_z"><i></i>满额包邮</span>
                </div>
            </div>
            <!--规格选取-->
            <div class="in_cut">
                选择商品规格
                <i class="icon-angle-right"></i>
            </div>
            <!--店铺详情-->
            <div class="cutWrap cut_four cF">
                <a href="javascript:;" class="cur">商品详情</a>
                <a href="javascript:;">售后服务</a>
            </div>
        </div>
        <!--商品参数和详情开始-->
        <div class="parem_wrapper" style='overflow:hidden'>
            <div class="parem_list image_list"><?=$goods_info['content']?></div>
            <div class="parem_list font_list hide"><?=$com['word']['shfw']['content']?></div>
        </div>
        <!--商品参数和详情结束-->
    </div>
    <div style="height:55px"></div>
    <!--底部菜单开始-->
    <div class="payBar_s fixed">
        <ul class="l">
            <a href="../index">
                <li class="bor"><i class="home icon-home" ></i> 首页</li>
            </a>
            <a href="../user/myCart">
                <li><i class="car icon-shopping-cart" > <em class="car-hasNum" id="buyCarMenu"><?=$cart_count?></em> </i> 购物车</li>
            </a>
        </ul>
        <ul class="r">
            <a href="javascript:;" onclick="showSku('add')" class="choose_type">
                <li class="one">加入购物车</li>
            </a>
            <a href="javascript:;" onclick="showSku('atOnce')" class="choose_type">
                <li class="two">立即购买</li>
            </a>
        </ul>
    </div>
    <!--底部菜单结束-->
    <!--规格选择弹出层开始-->
    <div class="paySelect fixed hide">
        <div class="sl_inner">
            <div class="sl_info">
                <dl>
                    <dt>
                        <img src="<?=$goods_info['pic']?>"/>
                    </dt>
                    <dd>
                        <p class="sl_name dyc"><?=$goods_info['title']?></p>
                        <p class="sl_sumy key" id="goodsPrice">￥<?=$goods_info['p_price']?></p>
                        <p class="sl_stock">库存：<span id="goodsSkuStock"><?=$goods_info['p_stock']?></span></p>
                    </dd>
                </dl>
                <span class="sl_close"></span>
            </div>
            <div class="item">
                <?php foreach($spec as $k=>$v): ?>
                <div class="item_box">
                    <h1><?=$k?>：</h1>
                    <ul class="wrap">
                        <?php foreach($v as $key=>$val): ?>
                            <li onclick="select_attr(this,<?=$goods_info['goods_id']?>)" class="<?=$val[1]?'cur':'';?>"><?=$val[0]?></li>
                        <?php endforeach; ?>
                    </ul>
                </div>
                <?php endforeach; ?>
                <div class="item_box">
                    <h1 class="fl">购买数量</h1>
                    <div class="conts fr">
                        <span class="sl_jian" onclick="editBuyNum('cut');"></span>
                        <input type="text" class="skuNum" id="buyCarNum" goodsskuid="" value="1"/>
                        <span class="sl_jia" onclick="editBuyNum('add');"></span>
                    </div>
                </div>
            </div>
            <div class="comfirm">
                <a onclick="addBuyCarSub()" class="sel_btn all_btn" addbuycartype="">确定</a>
            </div>
        </div>
    </div>
    <!--规格选择弹出层结束-->
    <script>
        $(function () {

            //选择规格的效果
            // $('.item_box').children('ul').find('li').click(function () {
            //     $(this).addClass('cur').siblings().removeClass('cur');
            // });
            //显示规格弹出层
            $('.choose_type,.in_cut').click(function () {
                $('.paySelect').show().children('.sl_inner').addClass('choose_animate');
                $(':root').addClass('root_fixed');
            });
            //关闭规格弹出层
            $('.sl_close').click(function () {
                $('.paySelect').hide().children('.sl_inner').removeClass('choose_animate');
                $(':root').removeClass('root_fixed');
            });
            //商品详情和售后服务的切换
            $('.cut_four').children('a').click(function () {
                $(this).addClass('cur').siblings().removeClass('cur');
                getid = $(this).index();
                $('.parem_list').eq(getid).show().siblings().hide();
            });
            //根据警示弹出层对应的文字做适当跳转
            $("#warnSure").click(function () {
                var warnWord = $("#warnWord").text();
                if (warnWord == "您未登录") {
                    window.location.href = root + "m/mUser/mUsLogin.php";
                }
            });
        });
        //轮播图
        TouchSlide({
            slideCell: "#Touchslide",
            titCell: "#TouchSort",
            mainCell: "#TouchMain",
            effect: "leftLoop",
            autoPage: true,
            autoPlay: false
        });

        //商品详情和售后服务的切换
        $('.cut_four').children('a').click(function(){
        	$(this).addClass('cur').siblings().removeClass('cur');
        	getid=$(this).index();
        	$('.parem_list').eq(getid).show().siblings().hide();
        });
        //收藏商品
        function mGoodsCollect(goodsId) {
            $.post("/user/goodscollect", {goodsid: goodsId}, function (data) {
                if (data.code == 0) {
                    $(".cut_collec i").css({"color": "#ff9900"});
                } else {
                    layer.msg(data.msg);
                }
            }, "json");
        }

        function select_attr(obj,goods_id) {
            // var price = $(obj).data("price");
            // var stock = $(obj).data("stock");
            // $("#goodsPrice").html("￥" + price);
            // $("#goodsSkuStock").html(stock);
            $(obj).siblings().removeClass("cur");
            $(obj).addClass("cur");
            var title = "";
            $(".item .item_box .wrap .cur").each(function(j,item){
                title += "_" + $(item).html();
            });
            $.ajax({
                url: "<?=url('goods/findgoods')?>",
                method: "post",
                data: {'title': title, "goods_id": goods_id},
                dataType: "JSON",
                success: function (d) {
                    if (d.code == 0) {
                        window.location.href = d.js.url;
                    } else {
                        layer.msg("没找到商品");
                    }
                }
            });
        }

        //显示规格弹出层逻辑函数
        function showSku(type) {
            $("[addBuyCarType]").attr("addBuyCarType", type);
        }

        //触发提交函数
        function addBuyCarSub() {
            var type = $("[addBuyCarType]").attr("addBuyCarType");
            buyCartGoods(type);
        }

        function buyCartGoods(type) {
            var attr_id = <?=$_GET['gid']?>;
            var nums = $("#buyCarNum").val();
            var goods_id = $("#goods_id").val();
            $.ajax({
                url: "<?=url('goods/addCart')?>",
                method: "post",
                data: {'attr_id': attr_id, "goods_id": goods_id, "nums": nums},
                dataType: "JSON",
                success: function (res) {
                    if (res.code == 100) {
                        warn(res.msg);
                    } else if (type == 'add') {
                        $("#cart_alert").show();
                    } else if (type == 'atOnce') {
                        my.action(res);
                    }
                }
            })
        }

        function warn_sure() {
        <?php if($c != 'publics' && !$userinfo): ?>
            window.location.href = "/publics/login";
        <?php endif; ?>
            $('#warn').hide()
        }

        function goCart() {
            window.location.href = "<?=url('user/myCart')?>";
        }
        function goIndex(){
            window.location.href = "<?=url('index')?>";
        }
    </script>
    <div class="hide" id="warn">
        <div class="dibian" style="z-index:100"></div>
        <div class="win" style=" width:300px;height:160px; margin:-80px 0 0 -150px;z-index:101;">
            <p class="winTitle">温馨提示<span onclick="$('#warn').hide()" class="winClose">×</span></p>
            <div id="warnWord">无</div>
            <div id="warnSure" onclick="warn_sure()">确定</div>
            <div id="warnCancel" onclick="$('#warn').hide()">取消</div>
        </div>
    </div>
    <div class="hide" id="cart_alert">
        <div class="dibian" style="z-index:100"></div>
        <div class="win" style=" width:300px;height:160px; margin:-80px 0 0 -150px;z-index:101;">
            <p class="winTitle">温馨提示<span onclick="$('#cart_alert').hide()" class="winClose">×</span></p>
            <div id="warnWord">添加购物车成功</div>
            <div id="warnSure" onclick="goCart()">前往购物车</div>
            <div id="warnCancel" onclick="$('#cart_alert').hide()">取消</div>
        </div>
    </div>
</body>
</html>
